<?php

namespace App\Http\Controllers\Test;

use App\Http\Controllers\Controller;
use App\Jobs\DemoJob;
use App\Service\WeChat\MiniWx;
use App\Service\WeChat\OpenWx;


class MiniController extends Controller
{
    // 队列测试
    public function initialize()
    {
        parent::initialize();
    }

    // 获取  AccessToken
    public function token()
    {
        $mini = new MiniWx();
        $res  = $mini->getAccessToken();

        return $this->success($res);
    }


    // 获取 openID:o4H167e6PNOYgpwJKihvj1ZdqIk4
    public function openid()
    {
        $mini   = new MiniWx();
        $token  = $mini->getAccessToken();
        $option = $this->optLogic();
        $code   = $option->getData('code', null, 'trim');
        if(empty($code)){
            return $this->error('请输入code！');
        }

        //$res = $mini->_getOpenid($token, $code);
        $res = $mini->getOpenidByMini($code);

        return $this->success($res);
    }

    // 获取用户信息
    public function getUser(){

    }

}


